<template>
	<view class="index-container">
		<view class="titleStyPOs">
			<div style="height:30rpx;"></div>
			<view :style="{height: statusBarHeight + 'px'}"></view>
			<div class="header">
				<div class="back flex-start ml-30 mr-30 " @click="back">
					<image :src="getImageUrl('/shopstatic/icon/back.png')" mode="widthFix" class="w-20 h-30"></image>
				</div>
				<u-search :placeholder="$t('请搜索')" :showAction="false" :animation="false" bgColor="#fff" v-model="keyword"
					class="searchSty" @search="goFilter" :height="78"></u-search>
					<view class="flex-start flex-start">
						<!-- <image src="../../../static/icon/positionIcon (2).png" mode="" class="w-22 h-22"></image> -->
						<view class="transport">
							<view class="transport_name">
						
						<city  :is_all="true" :value="paramsList.city_name" class="w-full" @change="e => {
								paramsList.city_name = e.column2.value == -1 || e.column3.value == -1 ?
								[e.column1.label, e.column2.label.replace('全部', ''), e.column3.label.replace('全部', '')].filter(item => item).join(',') :
								 e.column3.label;
								 paramsList.city_id = [e.column1.value, e.column2.value, e.column3.value].join(',');
								}">
						 <div :class="{ 'font-bold': paramsList.city_name, add_hidden: true,'acxx': paramsList.city_name}"
							 >
							 <!-- :class="{ 'font-bold': paramsList.city_name }"
							  :style="` ${paramsList.city_name} ? 'color:#333;max-width:80rpx' : 'color:#8c8c8c;max-width:auto' `" -->
					<!-- // :style="{ color: paramsList.city_name ? '#333' : '#8c8c8c' }" -->
								 {{ paramsList.city_name|| $t('请选择') }}
								</div>
							 </city>

							</view>
							<u-icon v-if="paramsList.city_id" name="close" color="#8C8C8C" size="24rpx" @click="delAddress"></u-icon>
							<u-icon name="arrow-down" color="#8C8C8C" size="24rpx"></u-icon>
						</view>
					</view>
			</div> 
			<tipSl :text="$t('【重要提示】交易前请核实服务方资质与评价！警惕超低价/夸大宣传，遇欺诈速联系平台举报，我们全力配合保障您的权益！')" style="margin: 0;background-color: transparent;"></tipSl>
			<div class="list-title w-full">
				<scroll-view scroll-x>
					<view class="scrolxxx">
						<view v-for="item in list" class="commonTitle" :class="{active: item.id==current}" @click="sectionChange(item.id)">
							{{ item[plang('name')] }}
						</view>
					</view>
				</scroll-view>
			</div>
		</view>
		<view :style="`height: calc(${statusBarHeight}px + 285rpx)`"></view>

		<view class="ml-24 mr-24 rounded-26" style="">
			<view class="" v-for="(item, index) in liveList" @click="goDetail(item)">
				<view class="flex-start infoBoxSty">
					<view class="center flex">
						<!-- aspectFit  aspectFill -->
						<image :src="getImageUrl((item.images && item.images.length > 0 && item.images[0]))" mode="aspectFill" class="w-170 h-170 mt-24 ml-24 mb-24" style="border-radius: 16rpx;"></image>
					</view>
					<view class="flex-1">
						<p class="text-010 fz28 pt-20 ml-24 font-bold">{{item[plang('person_name')]}}</p>
						<p class="priceSty" > <span class="fz20" >{{item.price_unit}}</span> {{item.price}} ~ {{item.price2}}</p>
						<view class="between ml-15 mr-15 pb-15 mt-10 infoBg">
							<view class="mt-15 ad_middle">
								<image :src="getImageUrl(get(item, 'user.avatar'))" mode="" class="w-35 h-35 vam rounded-500"></image>
								<span class="fz18 text-888 ml-20" style="width: 280rpx;" v-if="lang == 'zh'">{{get(item, 'user.nickname')}}</span>
								<span class="fz18 text-888 ml-20" style="width: 280rpx;" v-else>{{item[plang('user.nickname_ru')]}}</span>
							</view>
							<view class="flex mr-20">
								<view class="mt-15">
									<!-- <image src="../../../static/images/user/newUI/watchIcon.png" mode="" class="w-20 h-20 vam"></image> -->
									<image :src="getImageUrl('/shopstatic/images/user/newUI/watchIcon.png')" mode="" class="w-20 h-20 vam"></image>
									
									<!-- {{item.num}} -->
									<span class="fz22 text-888 ml-8">{{item.num}}</span>
								</view>
								<view class="mt-15 ml-20">
									<!-- <image src="../../../static/images/user/newUI/saveIcon.png" mode="" class="w-20 h-20 vam"></image> -->
									<image	:src="getImageUrl('/shopstatic/images/user/newUI/saveIcon.png')" mode="" class="w-20 h-20 vam"></image> 
								
									<!-- {{item.zan}} -->
									<span class="fz22 text-888 ml-8">{{item.zan}}</span>
								</view>
							</view>
						</view>
					</view>
				</view>
				
			</view>
			
		</view>
		
		<view class="releaseBox" @click="sendAdvertising">
			 <image  :src="getImageUrl('/shopstatic/icon/releaseIcon.png')" mode="" class="w-40 h-40"></image>
			 <!-- <image src="../../../static/icon/releaseIcon.png" mode="" class="w-40 h-40"></image> -->
			
			 <p class="fz22 text-white mt-10">{{$t('发布')}}</p>
		</view>
		
		<div v-if="nomore" class="center text-gray-500 fz24 pt-20 pb-20">{{$t('没有更多了')}}</div>
		<view class="h-50"></view>
	</view>
</template>

<script>
	import { getCcateProfessional, getProfessionalList  } from '@/api/basic'
	import citySelect from "./components/citySelect.vue"
	
	export default {
		components: {
			citySelect
		},
		data() {
			return {
				list: [],
				current: '',
				keyword: '',
				statusBarHeight: uni.getStorageSync('statusBarHeight') || 0,
				IMAGE_URL: 'https://gluz-oss.oss-cn-beijing.aliyuncs.com/',
				nomore: false,
				paramsList:{
					scope_category_id: '',
					city_id: '',
					city_name: '',
					page: 1,
					limit: 10,
					searchKey: ''
				},
				liveList: [],
				lang: uni.getStorageSync('lang')
			}
		},
		mounted() {
			this.getCcateProfessional();
		},
		  created() {
			// 刷新页面
				console.log('99999')
				if (this.paramsList.scope_category_id) {
					window.onNativeShow = this.getProfessionalList
				}
		  },
		watch: {
			'paramsList.city_id': {
				handler(val) {
					console.log('1111', this.paramsList.city_id)
					this.getProfessionalList(true)
				},
			}
		},
		methods: {
	

			goFilter(e) {
				this.paramsList.searchKey = e
				this.getProfessionalList(true)
			},
			delAddress() {
				this.paramsList.city_id = ''
				this.paramsList.city_name = ''
				this.getProfessionalList(true)
			},
			getCcateProfessional() {
				getCcateProfessional().then(res => {
					this.list = res.data.data || []
					this.current = this.list[0].id
					this.paramsList.scope_category_id = this.current
					this.getProfessionalList(true)

				})
			},
			//下拉刷新
			onPullDownRefresh() {
				this.getProfessionalList(true)
			},
			//上拉加载
			onReachBottom() {
				this.paramsList.page++
				this.getProfessionalList()
			},
			getProfessionalList(init) {
				if (init) {
					this.paramsList.page = 1
					this.nomore = false;
				}
				if (this.nomore) {
					return;
				}
				uni.showLoading({
					title: 'loading',
					mask: true
				})
				getProfessionalList({...this.paramsList,location_city: this.paramsList.city_id,city_id: ''}).then(res => {
					if (this.paramsList.page == 1) {
						this.liveList = res.data.data
					} else {
						this.liveList = [...this.liveList, ...res.data.data]
					}
					//当前请求的{{$t('列表')}}{{$t('是')}}空的 那就{{$t('是')}}没有更多了
					if (res.data.data.length == 0) {
						this.nomore = true;
					}
					// 结束下拉刷新
					uni.hideLoading()
					uni.stopPullDownRefresh()
				}).catch(err => {
					uni.hideLoading()
					uni.stopPullDownRefresh()
				})
			},
			
			sectionChange(index) {
				this.keyword = ''
				this.paramsList.searchKey = ''
				this.current = index
				this.paramsList.scope_category_id = index
				this.liveList = [];
				this.getProfessionalList(true)
			},
			back() {
				uni.navigateBack()
				// uni.navigateTo({
				// 	url:'/pages/app/index',
				// 	webview: 'zWebView',
				// })
			},
			goDetail(item) {
				// console.log(item,'sdsdd')
				uni.setStorageSync('allinfo',item)
				uni.navigateTo({
					url: `/pages/tabbar/professionalList/professDetail/professDetail`
					
				})
			},
			sendAdvertising() {
				uni.navigateTo({
					url: '/pages/tabbar/professionalList/sendAdvertis'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/assets/appScss.scss';
	page {
		background-color: #F6F7FB;
	}
	.index-container {
		width: 100%;
		height: 100vh;
		// background: #F6F7FB url("/static/backcolorImg.png") no-repeat top / 100%;
		// position: relative;
		// z-index: 5;
		// position: fixed;
		// z-index: 60;
	}
	.titleStyPOs {
		background: #F6F7FB url("https://gluz-oss.oss-cn-beijing.aliyuncs.com/shopstatic/backcolorImg.png") no-repeat top / 100%;
		position: fixed;
		width: 100%;
		z-index: 10;
	}
	.infoBoxSty {
		background-color: #fff;
		// margin-left: 24rpx;
		// margin-right: 24rpx;
		border-bottom: 1rpx solid #F0F0F0;
	}
	// .infoBoxSty:first-child{
	// 	border-radius: 26rpx 26rpx 0 0;
	// }
	.liveBoxLeft {
		float: left;
		width: 50%;
		image {
			width: 340rpx;
			height: 326rpx;
		}
		.liveInfoBox {
			width: 340rpx;
			min-height: 100rpx;
			border-radius: 0 0 18rpx 18rpx;
		}
	}
	.liveBox {
		width: 50%;
		float: right;
		image {
			width: 340rpx;
			height: 326rpx;
		}
		.liveInfoBox {
			width: 340rpx;
			min-height: 100rpx;
			border-radius: 0 0 18rpx 18rpx;
		}
	}
	
	.header {
		font-size: 34rpx;
		font-weight: bold;
		position: relative;
		display: flex;
		align-items: center;
		.searchSty {
			
			
		}
	}
	
	.transport {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		flex: 1;
		margin: 0 16rpx;
		.transport_name {
			white-space: wrap;
			overflow: hidden;
			text-overflow: ellipsis;
			max-width: 200rpx;
			color: #0e0e0e;
			font-size: 22rpx;
			margin-right: 8rpx;
		}
	}
	
	.list-title {
	
		.scrolxxx {
			display: flex;
			padding: 26rpx 0;
			padding-top: 0;
		}
		.commonTitle {
			height: 46rpx;
			flex: 0 0 auto;
			// width: 120rpx;
			font-size: 28rpx;
			color: #535353;
			margin-left: 25rpx;
		}
		.active {
			font-size: 28rpx;
			color: #278AFF;
			font-weight: 600;
			&::after {
				content: '';
				display: block;
				width: 50rpx;
				height: 4rpx;
				background: #278AFF;
				margin: 0 auto;
				margin-top: 3rpx;
			}
		}
	}
	.priceSty {
		color: #FF7000;
		font-size: 30rpx;
		margin-left: 16rpx;
		margin-top: 20rpx;
	}
	.infoBg {
		background-image: url('https://gluz-oss.oss-cn-beijing.aliyuncs.com/shopstatic/images/user/newUI/userinfoBg.png');
	}
	.releaseBox {
		width: 156rpx;
		height: 156rpx;
		border-radius: 500rpx;
		background: linear-gradient(90deg, #278AFF 0%, #66D6E2 100%);
		box-shadow: 0rpx 4rpx 13.8rpx 0rpx #DEE1EF;
		box-shadow: -2rpx -6rpx 9.9rpx 0rpx #71D0FF inset;
		box-shadow: -4rpx 5rpx 6.5rpx 0rpx #C8FBFF75 inset;
		position: fixed;
		z-index: 10;
		right: 40rpx;
		bottom: 150rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.add_hidden{
		white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
	font-size: 26rpx;
	color:#8c8c8c !important; max-width:auto
	}
	.ad_middle{
		display: flex;
		align-items: flex-start;
		.text-888{
			white-space: nowrap;    
			overflow: hidden;       
			text-overflow: ellipsis;
		}
	}

</style>
